package org.mozhu.mboot.backend.security;

import lombok.Builder;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Data
@Builder
public class IdentifiedUserDetails implements UserDetails {
    private Long id;
    private String username;
    private String password;
    private List<GrantedAuthority> authorities;
    @Builder.Default
    private boolean accountNonExpired = true;
    @Builder.Default
    private boolean accountNonLocked = true;
    @Builder.Default
    private boolean credentialsNonExpired = true;
    private boolean enabled;
    private Map<String, Serializable> details;

    public IdentifiedUserDetails addDetail(String key, Serializable value) {
        details.put(key, value);
        return this;
    }

    public Serializable getDetail(String key) {
        return details.get(key);
    }
}
